#include <stdbool.h>

#include "../BSP/pwm.h"

/*     LEAF      */
/* _____________ */
/* |           | */
/* |     ①     | */
/* |           | */
/* |___________| */
/* |    |||    | */
/* |    |||    | */
/* |    |||    | */
/* |    |||    | */
/* |    |②|   ③| */
/* |    |||    | */
/*  \   |||   /  */
/*   \  |||  /   */
/*    \ ||| /    */
/*     -----     */

/* 各区域灯珠数量 */
#define FIRST_HEIGHT (26)
#define FIRST_WIDTH (38)
#define SECOND_LENTH (60)
#define SECOND_NUMBER (5)
#define THIRD_LENTH (155)
/* 总数量 */
#define LED_NUMBER                                                    \
  (((FIRST_HEIGHT + FIRST_WIDTH) * 2 + SECOND_LENTH * SECOND_NUMBER + \
    THIRD_LENTH))
#define LED_SIZE (LED_NUMBER * 8 * 3)
#define DATA_SIZE (LED_SIZE + 4 * 20)

typedef enum { LEAF_OFF, LEAF_HAMMER, LEAF_SWORD } LED_Leaf_Mode_t;

typedef enum {
  LEAF_2_2,
  LEAF_2_3,
  LEAF_2_4,
  LEAF_3_1,
  LEAF_3_4,
  LEAF_NUMBER
} LED_Leaf_Name_t;

void LED_PackData(LED_Leaf_Mode_t mode);

/**
 * @brief 灯带初始化
 *
 */
void LED_Init(void);

/**
 * @brief 更新灯带状态
 *
 * @param test 是否为测试模式
 */
void LED_Update(bool test);

/**
 * @brief 将一个新的扇叶设为可打击状态
 *
 */
void LED_EnableOneLeaf(void);

/**
 * @brief 重置灯带状态
 *
 */
void LED_Reset(void);

/**
 * @brief 检测某个扇叶是否可打击
 *
 * @param name
 * @return true
 * @return false
 */
bool LED_CheckLeaf(LED_Leaf_Name_t name);
